package han.temp;

import han.entity.FinanceProjectBaseInfoEntity;
import han.entity.FinanceProjectFinanceEntity;
import han.entity.FinanceProjectMemberEntity;
import han.entity.FinanceProjectNewsEntity;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: Han
 * @date: 2018/7/16 15:07
 * @dscription: TODO
 */
public class TempFinanceInfoEntity {
    private FinanceProjectBaseInfoEntity baseInfoEntity;

    private List<FinanceProjectFinanceEntity> financeEntityList;

    private List<FinanceProjectMemberEntity> memberEntityList;

    private List<FinanceProjectNewsEntity> newsEntityList;

    public TempFinanceInfoEntity(FinanceProjectBaseInfoEntity baseInfoEntity, List<FinanceProjectFinanceEntity> financeEntityList, List<FinanceProjectMemberEntity> memberEntityList, List<FinanceProjectNewsEntity> newsEntityList) {
        this.baseInfoEntity = baseInfoEntity;
        this.financeEntityList = financeEntityList;
        this.memberEntityList = memberEntityList;
        this.newsEntityList = newsEntityList;
    }

    public Map<String, String> generateMap() {
        String name = baseInfoEntity.getFullName();
        String projectName = baseInfoEntity.getName();
        String website = baseInfoEntity.getWebsite();
        String industryTag = baseInfoEntity.getIndustryTag();
        String intro = baseInfoEntity.getIntro();
        String phase = "";
        String amount = "";
        String amountUnit = "";
        String investName = "";
        String financeDate = "";
        StringBuilder financeExperienceSB = new StringBuilder();
        for (FinanceProjectFinanceEntity entity : financeEntityList) {
            phase = entity.getPhase();
            amount = entity.getFinanceAmount();
            amountUnit = entity.getFinanceAmountUnit();
            investName = entity.getInvestIds().replaceAll("[,].*","");
            financeDate = entity.getFinanceDate().toString();
            financeExperienceSB.append("轮次:").append(phase).append(",融资金额:").append(amount).append(amountUnit)
                    .append("融资方:").append(investName).append(",日期:").append(financeDate).append("\n");
        }
        StringBuilder member = new StringBuilder();
        for (FinanceProjectMemberEntity entity : memberEntityList) {
            String memberName = entity.getName();
            String memberIntro = entity.getIntro();
            String position = entity.getPosition();
            member.append("姓名:").append(memberName).append(",职位:").append(position).append(",简介").append(memberIntro).append("\n");
        }
        StringBuilder news = new StringBuilder();
        for (FinanceProjectNewsEntity entity : newsEntityList) {
            String type = entity.getNewsType();
            String url = entity.getNewsUrl();
            String source = entity.getSource();
            String title = entity.getTitle();
            String publishDate = entity.getPublishDate().toString();
            news.append("类型:").append(type).append(",标题:").append(title).append(",日期:").append(publishDate).append(",链接:").append(url).append(",来源:").append(source).append("\n");
        }

        Map<String, String> map = new LinkedHashMap<>();
        map.put("名称", name);
        map.put("邮件", baseInfoEntity.getEmail());
        map.put("电话", baseInfoEntity.getPhone());
        map.put("地区", baseInfoEntity.getArea());
        map.put("网站", website);
        map.put("地址", baseInfoEntity.getAddr());
        map.put("项目名称", projectName);
        map.put("标签", industryTag);
        map.put("项目介绍", intro);
        map.put("融资情况", financeExperienceSB.toString());
        map.put("融资轮次", phase);
        map.put("融资金额", amount);
        map.put("货币单位", amountUnit);
        map.put("融资机构", investName);
        map.put("融资时间", financeDate);
        map.put("创始团队", member.toString());
        map.put("相关报道", news.toString());
        map.put("联系人姓名", "");
        map.put("头衔", "");
        map.put("手机", "");
        map.put("邮箱", "");
        map.put("微信号", "");

        return map;
    }
}
